﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Data;

namespace unTroublemakerUI.Extensions
{
    [ValueConversion(typeof(bool), typeof(Visibility))]
    public class InverseBoolToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is bool)
            {
                var visible = !(bool) value;
                return visible ? Visibility.Visible : Visibility.Collapsed;
            }

            throw new InvalidOperationException("Value is not supported, only boolean values are supported: " + value);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new InvalidOperationException("Only one-way conversion is allowed");
        }
    }
}
